from requests import session

from api.api_register_login import logger
from config import HOST
from tools import GetLog

logger = GetLog.get_logger()
class ApiApproveTrust:
    def __init__(self,session):
        # 获取session对象
        self.session = session
        # 1、认证接口URL
        self.__url_approve=HOST+"/member/realname/approverealname"
        # 2、查询认证状态URL
        self.__url_approve_status = HOST + "/member/member/getapprove"
        # 3、开户接口URL
        self.__url_trust = HOST + "/trust/trust/register"
    # 1、认证接口 封装
    def api_approve(self,realname="张三",card_id="81000020050525460X"):
        approve_data = {
            "realname":realname,
            "card_id":card_id
        }
        logger.info("调用认证接口,请求方法:post,请求URL:{},请求数据:{}".format(self.__url_approve, approve_data))
        # 对于multipart-form/data->data+files
        return self.session.post(url=self.__url_approve,data=approve_data,files={"x":"y"})
    # 2、查询认证状态接口 封装
    def api_approve_status(self):
        logger.info("调用认证接口,请求方法:post,请求URL:{}".format(self.__url_approve_status))
        return self.session.post(url=self.__url_approve_status)
    # 3、开户接口 封装
    def api_trust(self):
        logger.info("调用认证接口,请求方法:post,请求URL:{}".format(self.__url_trust))
        return self.session.post(url=self.__url_trust)